<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='ttbl' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {
            background: #fff;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

        <form:form commandName="giftActivity" method="${_method }" class="layui-form" id="form">
            <input type="hidden" name="_method" value="${_method }"/>
            <form:hidden path="id"/>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='zphdmc' /></label>
                <div class="layui-form-mid layui-word-aux">
                        ${giftActivity.name}
                </div>
            </div>

            <div class="layui-form-item feijin-zenpin-area">
                <label class="layui-form-label"><fmt:message key='zp' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <table class="layui-table" lay-size="sm" id="feijin-sku-table">
                        <thead>
                        <tr>
                            <th><fmt:message key='spbh' /></th>
                            <th><fmt:message key='spmc' /></th>
                            <th><fmt:message key='sptp' /></th>
                        </tr>
                        </thead>
                        <tbody id="giftGoodsArea">

                        <c:if test="${_method eq 'PUT'}">

                            <c:forEach items="${giftGoodses}" var="item">

                                <tr data-id='${item.goods.id}' class='feijin-giftGoods-ids'>
                                    <td>${item.goods.goodsNo}</td>
                                    <td>${item.goods.name}</td>
                                    <td><img class="preview" style="width:40px;height:40px;" src="${store_domain}/uploads/${item.goods.defaultImage}"/></td>
                                </tr>

                            </c:forEach>
                        </c:if>

                        </tbody>

                    </table>

                </div>
            </div>


            <div class="layui-form-item feijin-validityType-gudin-area">
                <label class="layui-form-label"> <fmt:message key='zpyxq' /></label>
                <div class="layui-form-mid layui-word-aux">
                        ${giftActivity.beginDateOfValidity} - ${giftActivity.endDateOfValidity}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='mkje' /></label>
                <div class="layui-form-mid layui-word-aux">
                        ${giftActivity.standardsAmount}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='sysplx' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:if test="${giftActivity.scopeGoodsType eq 1}"><fmt:message key='suoysp' /></c:if>
                    <c:if test="${giftActivity.scopeGoodsType eq 2}"><fmt:message key='zdsp' /></c:if>
                    <c:if test="${giftActivity.scopeGoodsType eq 3}"><fmt:message key='zdfl' /></c:if>
                </div>
            </div>


            <div class="layui-form-item" style="display:none;" id="feijin-scopeGoods">
                <label class="layui-form-label"> <fmt:message key='sysp' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th><fmt:message key='spbh' /></th>
                            <th><fmt:message key='spmc' /></th>
                            <th><fmt:message key='sptp' /></th>
                        </tr>
                        </thead>
                        <tbody id="feijin-chooseGoods-table">
                        <c:if test="${_method eq 'PUT'}">

                            <c:forEach items="${giftScopes}" var="item">

                                <tr data-id='${item.goods.id}' class='feijin-scopeGoods-ids'>
                                    <td>${item.goods.goodsNo}</td>
                                    <td>${item.goods.name }</td>
                                    <td><img style='width:30px;' src='${store_domain}/uploads/${item.goods.defaultImage}'/></td>
                                </tr>

                            </c:forEach>
                        </c:if>

                        </tbody>
                    </table>
                </div>
            </div>

            <div class="layui-form-item" style="display:none;" id="feijin-channels">
                <label class="layui-form-label"> <fmt:message key='splm' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:if test="${_method eq 'PUT'}">
                        <c:forEach items="${channels}" var="item">
                            <c:if test="${fn:contains(channelNames, item.name)}">${item.name}</c:if>
                        </c:forEach>
                    </c:if>
                </div>
            </div>

        </form:form>
    </div>
</div>
<script>
    $(function () {

        var id = "${giftActivity.scopeGoodsType}";

        if (id == 1) {
            $("#feijin-scopeGoods").hide();
            $("#feijin-channels").hide();
        }

        if (id == 2) {
            $("#feijin-scopeGoods").show();
            $("#feijin-channels").hide();
        }

        if (id == 3) {
            $("#feijin-scopeGoods").hide();
            $("#feijin-channels").show();

        }

    });


    layui.use(['form', 'laydate'], function () {

        var form = layui.form;
        var laydate = layui.laydate;

    });
</script>
</body>
</fmt:bundle>
</html>